package com.oa.action;

import java.io.InputStream;
import java.util.List;

import javax.annotation.Resource;

import org.jbpm.api.ProcessDefinition;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.oa.entity.LiuChengDingYi;
import com.oa.service.LiuChengDingYiService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

/**
 * @author FengMengHuo
 * 流程定义action
 */
@Controller
@Scope("prototype")
public class LiuChengDingYiAction extends ActionSupport implements ModelDriven<LiuChengDingYi>{
	private static final long serialVersionUID = 1L;
	private LiuChengDingYi liuChengDingYi = new LiuChengDingYi();
	
	@Resource(name="liuChengDingYiService")
	private LiuChengDingYiService liuChengDingYiService ;
	
	//流程定义列表
	public String list(){
		
		System.out.println("====================");
		List<ProcessDefinition> processDefinitionList =  liuChengDingYiService.findLiuChengDingYiList();
		System.out.println(processDefinitionList.size()+"--------------------");
		ActionContext.getContext().put("pList", processDefinitionList);
		return "list";
	}
	//部署流程定义页面
	public String addPage(){
		return "savePage";
	}
	//添加流程定义
	public String add(){
		System.out.println(liuChengDingYi.getUpload()+"----------------");
		// 部署流程定义
		liuChengDingYiService.buShuLiuChengDingYi(liuChengDingYi);
		return "toList";
	}
	//删除流程定义
	public String delete(){
		liuChengDingYiService.deleteLiuChengDingYi(liuChengDingYi);
		return "toList";
	}
	// 查看流程图
	public String lookImage(){
		InputStream inputStream = liuChengDingYiService.lookImageById(liuChengDingYi);
		liuChengDingYi.setInputStream(inputStream);
		return "lookImage";
	}
	public LiuChengDingYi getModel() {
		return liuChengDingYi;
	}

}
